package com.tengyun.middleplatform.trade.etl.model.base;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.Version;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.tengyun.middleplatform.trade.etl.util.LongJsonDeserializer;
import com.tengyun.middleplatform.trade.etl.util.LongJsonSerializer;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 实体基础信息
 */
@Getter
@Setter
public class BaseEntity implements Serializable {

    /**
     * 主键id
     */
    @JsonDeserialize(using = LongJsonDeserializer.class)
    @JsonSerialize(using = LongJsonSerializer.class)
    @TableId(type = IdType.AUTO)
    protected Long id;
    @Version
    protected Integer version;
    protected LocalDateTime lastUpdDt;
    protected LocalDateTime createdDt = LocalDateTime.now();
    protected String createdBy = "settlement";
    protected String lastUpdBy;

    public void setBasePublicParam(LocalDateTime createdDt, String createdBy, LocalDateTime lastUpdDt, String lastUpdBy, Integer version) {
        this.createdDt = createdDt;
        this.createdBy = createdBy;
        this.lastUpdDt = lastUpdDt;
        this.lastUpdBy = lastUpdBy;
        this.version = version;
    }
}
